package whatIsIt;
import java.io.BufferedReader;
import java.io.FileReader;
import java.io.IOException;
import java.text.ParseException;
import java.text.SimpleDateFormat;
import java.util.Date;
import java.util.Scanner;
class ActivityFinder {
	static void main(String[] args) {
		Scanner scanner = new Scanner(System.in);
		SimpleDateFormat dateFormat = new SimpleDateFormat("MM.dd");
		Date inputDate = null;
		while (inputDate == null) {
			try {
				System.out.print("输入日期 (如11.25): ");
				String input = scanner.nextLine();
				inputDate = dateFormat.parse(input);
			} catch (ParseException e) {
				System.out.println("无效的日期，请重试");
			}
		}
		try {
			BufferedReader reader = new BufferedReader(new FileReader("IO.txt"));
			String line;
			boolean found = false;
			while ((line = reader.readLine()) != null) {
				if (line.matches("^\\d{1,2}\\.\\d{1,2}-\\d{1,2}\\.\\d{1,2}$")) {
					String[] dates = line.split("-");
					Date startDate = dateFormat.parse(dates[0]);
					Date endDate = dateFormat.parse(dates[1]);
					if (inputDate.compareTo(startDate) >= 0 && inputDate.compareTo(endDate) <= 0) {
						found = true;
						System.out.println( dateFormat.format(inputDate) + "安排的活动:");
					}
					else {
						found = false;
					}
				}
				if (found && !line.trim().isEmpty()) {
					System.out.println("- " + line.trim());
				}
			}
			reader.close();
		} catch (IOException e) {
			System.out.println("读取文件错误: " + e.getMessage());
		} catch (ParseException e) {
			System.out.println("Error parsing the dates: " + e.getMessage());
		}
	}
}
class Main{
	public static void main(String[] args) {
		ActivityFinder.main(args);
	}
}
